package pers.xhh.frontapi.entity.vo.order;


import pers.xhh.frontapi.entity.MiReceiverEntity;

import java.math.BigDecimal;
import java.util.List;

/**
 * @author wei-xhh
 * @date 2020-12-09
 */
public class OrderConfirmVo {
    /**
     * 收货地址
     */
    List<MiReceiverEntity> address;
    /**
     * 所有选中的购物项
     */
    List<OrderItemVo> items;
    /**
     * 防重令牌
     */
    String orderToken;
    /**
     * 订单总额
     */
    BigDecimal total;

    public Integer getCount(){
        Integer i = 0;
        if(items != null){
            for (OrderItemVo item : items) {
                i+=item.getCount();
            }
        }
        return i;
    }

    public BigDecimal getTotal() {
        BigDecimal sum = new BigDecimal("0");
        if(items != null){
            for (OrderItemVo item : items) {
                BigDecimal multiply = item.getPrice().multiply(new BigDecimal(item.getCount().toString()));

                sum = sum.add(multiply);
            }
        }

        return sum;
    }

    //应付价格
//    BigDecimal payPrice;

    public BigDecimal getPayPrice() {
        return getTotal();
    }

    public List<MiReceiverEntity> getAddress() {
        return address;
    }

    public void setAddress(List<MiReceiverEntity> address) {
        this.address = address;
    }

    public List<OrderItemVo> getItems() {
        return items;
    }

    public void setItems(List<OrderItemVo> items) {
        this.items = items;
    }

    public String getOrderToken() {
        return orderToken;
    }

    public void setOrderToken(String orderToken) {
        this.orderToken = orderToken;
    }

    public void setTotal(BigDecimal total) {
        this.total = total;
    }
}
